import { tranRecordType } from "../types/trarecord";
import request from "../utils/request";
// 获取学生
interface objType {
    objectId: string;
}
export const studentGet = (objectId?: objType) => {
    let where = objectId ? `/${objectId}` : ''
    return request.get(`classes/student${where}`)
}

// 获取教练

export const coachGet = (obj?: objType) => {
    return request.get(`classes/coachList`, {
        params: {
            where: { object: obj }
        }
    })
}

// 获取车辆
export const carGet = () => {
    return request.get("classes/car")
}
// 新增学员练车记录
export const tranrecorddPost = (data: tranRecordType) => {
    return request.post("classes/tranRecord", data)
}
// 获取学员记录




export const tranrecorddGet = (name?: any) => {
    console.log(name)
    return request.get("classes/tranRecord")
}
// 删除记录
export const tranRecorddDelete = (objectId: any) => {
    return request.delete(`classes/tranRecord/${objectId}`)
}

// 批量修改
export const orderPut = (ids: Array<string>, obj: tranRecordType) => {
    let requests = ids.map((id) => {
        return {
            method: "PUT",
            //path是后端接口，严格按照文档配置路径
            path: `/1.1/classes/MockExam/${id}`,
            body: obj
        };
    });
    return request.post("batch", { requests });
};

// 累计练车时长
export const totalInc=(objectId:string,tratime:number)=>{
    return request.put(`classes/tranRecord/${objectId}`, {
        "upvotes": {"__op":"Increment","amount":tratime}
    })
}